<?php


namespace app\privatearea\controller\v1;


use app\common\lib\Util;
use app\common\model\Recode;
use app\privatearea\controller\Auth;

class User extends Auth
{
    public function personal()
    {
        $RecodeModel = new Recode();
        $rea = $RecodeModel->getSelfRecode(['uid' => $this->user['id']]);
        if ($rea)
        {
            $utilModel = new Util();
            $sex = $rea['type'] == 1 ? 1 : 2;
            $data = [
                'name' => $rea['name'],
                'avatar' => $rea['avatar'],
                'sex' => $sex,
                'sun' => '日' . mb_substr($utilModel->recodeAstro($rea['sun']), 0, 2),
                'moon' => '月' . mb_substr($utilModel->recodeAstro($rea['moon']), 0, 2),
                'asc' => '升' . mb_substr($utilModel->recodeAstro($rea['asc']), 0, 2),
            ];
        } else
        {
            $data = [
                'name' => $this->user['nickname'],
                'avatar' => $this->user['avatar'],
                'sex' => 0,
                'sun' => '',
                'moon' => '',
                'asc' => '',
            ];
        }

        return show(config('code.success'), '请求成功', $data);
    }

}
